package com.chapter4.superprivatefinal.demo2;


/**
 * private变量只可以在类内调用，可以提供public get\set方法类外调用
 * 子类不可访问父类private方法，子类也不可覆盖父类private方法
 */
public class Fish extends Animal {

    public Fish(int height,int weight){
        //调用父类带参构造方法
        super(height,weight);
    }

    public void breathe(){
        System.out.println("Fish breathe");
    }


    public void swim(){
        //类内可以调用私有方法
        log();
        System.out.println("Fish swim");
    }

    private void log(){
        System.out.println("Fish log");
    }

    public static void main(String[] args) {
        Animal animal = new Animal(50,100);
        //an.height = 40 ; 在类外访问不了私有成员变量
        System.out.println(animal.getHeight());

        animal.setHeight(40);
        System.out.println(animal.getHeight());

        Fish fish =new Fish(5,10);
        fish.swim();

    }

}